package com.foton.springbootdemo.controller;

import com.fonton.ft.common.entity.Custom;
import com.foton.springbootdemo.entity.UserCustom;
import com.foton.springbootdemo.event.DomainEventBus;
import com.foton.springbootdemo.event.example.entity.ZsEquireMacineEvent;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author RenPu
 * @Date 2023/3/24 16:08
 * @Version 1.0
 * @Description:
 **/
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class TestController {

   private final UserCustom userCustom;

   private final Environment environment;


   private final Custom custom;

   @Resource
   private DomainEventBus domainEventBus;

    @RequestMapping("/index")
    public String index(){
//        String name=userCustom.getName();
//        String property = environment.getProperty("name");
//        return name+userCustom.getAge()+"从environment中进行获取的值: {}"+property;
        return "";
    }


    @RequestMapping("/testStarter")
    public String testStarter(){

        // 发布领域事件
        ZsEquireMacineEvent zsEquireMacineEvent =new ZsEquireMacineEvent();
        zsEquireMacineEvent.setMachineCode("ZS_QGJ_001");
        zsEquireMacineEvent.setSupplyName("制丝切割机");
        zsEquireMacineEvent.setSupplyCode("BJ_CY_CP");
        zsEquireMacineEvent.setSupplyName("北京朝阳凤凰机械重工有限公司");
        domainEventBus.post(zsEquireMacineEvent);


       return custom.doSomething();
    }



}
